﻿using Common.Communal;
using ERP.Domain.System;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using System.Api.Read.Applications.Commands.Roles;

namespace System.Api.Read.Controllers
{
    /// <summary>
    /// 角色
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoleController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">中介者</param>
        public RoleController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取角色
        /// </summary>
        /// <param name="command">命令</param>
        /// <returns>返回结果</returns>
        [HttpGet]
        public Task<ApiResult<List<Role>>> GetRole([FromQuery] RoleQueryCommand command)
        {
            return mediator.Send(command);
        } 
    }
}
